import java.awt.Point;

public class PowerPlant extends MapObject {

	private int batteriesCount;
	private static long lastId;
	private int productionTimeRemaining;

	public PowerPlant(Point p) {
		super(p);
		setBatteryCount(0);
		setProductionTimeRemaining(2);
	}

	public void produceApple() {
		setProductionTimeRemaining(getProductionTimeRemaining() - 1);
		if(getProductionTimeRemaining() == 0)
		{
		incrementBattery();
		setProductionTimeRemaining(6);
		}
	}


	public void incrementBattery() {
		if(getBatteryCount()<5)
		{
		setBatteryCount(getBatteryCount() + 1);
		}
	}

	public void decrementBattery() {
		if(getBatteryCount()>0)
		{
		setBatteryCount(getBatteryCount() - 1);
		}
	}

	public MapObjectType getType() {
		return MapObjectType.PowerPlant;
	}

	public int getBatteryCount() {
		return batteriesCount;
	}
	
	private void setBatteryCount(int batteriesCount) {
		this.batteriesCount = batteriesCount;
	}

	private int getProductionTimeRemaining() {
		return productionTimeRemaining;
	}

	private void setProductionTimeRemaining(int productionTimeRemaining) {
		this.productionTimeRemaining = productionTimeRemaining;
	}


	@Override
	public String toString() {
		String s = super.toString();
		return s + ", producing : " + getProductionTimeRemaining();
	}

	public boolean hasBattery() {
		return getBatteryCount() > 0;
	}

	
	
}